import request from '../../utils/request'

// 智能回答
export function getAnswer(question) {
    let url = 'api/query/?'//拼凑Get请求来请求数据
    if (question) {
        url += 'question=' + question
    }
    console.log(url)
    return request.get(url)
}

// 得到数据
export function getData(page) {
    let url = 'http://localhost:8000/readfood?'//拼凑Get请求来请求数据
    // let url = 'api/readfood/?'//拼凑Get请求来请求数据
    if (page) {
        url += 'page=' + page
    }
    console.log(url)
    // request.get(url)
    return request.get(url)//获取相应的数据
}

export function getTotal() {
    let url = 'http://localhost:8000/foodpagenum'//拼凑Get请求来请求数据
    // let url = 'api/foodpagenum/'//拼凑Get请求来请求数据
    return request.get(url)//获取相应的数据
}

export function getSearch(text, page) {
    let url = 'http://localhost:8000/searchfood?name='//拼凑Get请求来请求数据
    // let url = 'api/searchfood/?name='//拼凑Get请求来请求数据
    if (text)
        url += text
    url += "&page="
    if (page)
        url += page
    return request.get(url)//获取相应的数据
}

export function getDetail(herbname) {
    let url = 'http://localhost:8000/detailfood?name='//拼凑Get请求来请求数据
    // let url = 'api/detailfood/?name='//拼凑Get请求来请求数据
    if (herbname)
        url += herbname
    return request.get(url)//获取相应的数据
}

// 根据Id得到数据
export function getDataById(id) {
    let url = 'api/content/Content/' + id + '/'
    return request.get(url)
}

// 推荐
export function recommand(nodeName) {
    let url = 'api/neo4jEditor/node/command/?nodeName=' + nodeName
    return request.get(url)
}
